package com.zeta.api.client.auth;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * 鉴权服务 Feign接口降级处理
 *
 * @author gcc
 */
@Slf4j
@Component
public class IAuthApiFallbackFactory implements FallbackFactory<IAuthApi> {

    @Override
    public IAuthApi create(Throwable cause) {
        log.error("鉴权服务 feign接口调用失败: {}", cause.getMessage());

        return new IAuthApi() {
            @Override
            public List<String> permissions(Object loginId, String loginType) {
                return Collections.emptyList();
            }

            @Override
            public List<String> roles(Object loginId, String loginType) {
                return Collections.emptyList();
            }
        };
    }

}
